package ssau.knyazev.mmoi.module;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;

import ssau.knyazev.core.image.ImageModel;
import ssau.knyazev.mmoi.ModelSettings;

public class ImageGenerator {

	private static final ImageGenerator inst = new ImageGenerator();
	
	private ImageGenerator(){};
	
	public static ImageGenerator getInst(){
		return inst;
	}
	
	public ImageModel generateImage(int width, int height, int xMove, int yMove){
		int oy = width/2;

		ImageModel result = new ImageModel(width, height);
		for (int i = 0; i < width; i++){
			for (int j = 0; j < height; j++){
				result.getValues()[i][j] = ModelSettings.F;
			}
		}
		BufferedImage bi = result.getBufferedImage();
		Graphics g = bi.getGraphics();
		
		g.setColor(new Color(ModelSettings.X, ModelSettings.X, ModelSettings.X));
		for (double t = 0; t < height; t = t + 0.1){
			int i = height - (int)(t + 0.5) - 1;
			double f = ModelSettings.getF1(t);
			int j = (int)(oy + f);
			g.drawOval(j, i, ModelSettings.d, ModelSettings.d);
			f = ModelSettings.getF2(t);
			j = (int)(oy + f);
			g.drawOval(j, i, ModelSettings.d, ModelSettings.d);
			f = ModelSettings.getF3(t);
			j = (int)(oy + f);
			g.drawOval(j, i, ModelSettings.d, ModelSettings.d);
		}
		return new ImageModel(bi);
	}

	
	
	
}
